package com.mervin.helper;

import com.mervin.annotation.LineFieldAnnotation;
import com.mervin.annotation.LineParseAnnotation;
import com.mervin.enums.LineParseTypeEnum;

/***************************************
 * @author: mervin
 * @Date: 2020-05-04 14:32
 * @Description:
 ***************************************/
public class ProcessFactory {

    public static ParseProcess getProcess(Class<?> clazz){

        LineParseAnnotation lineParseAnnotation = clazz.getDeclaredAnnotation(LineParseAnnotation.class);
        LineParseTypeEnum lineParseTypeEnum = lineParseAnnotation.parseType();

        if(lineParseTypeEnum == null){
            return null;
        }

        switch (lineParseTypeEnum){
            case SEPARATE:
                return new SeparateParseProcess();
            case FIXED:
                return new FixLengthParseProcess();
            default:
                return null;
        }
    }
}
